package com.blrs.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.blrs.domain.StageServiceLog;
import com.blrs.service.project.servicelog.IStageServiceLogService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.blrs.common.annotation.Log;
import com.blrs.common.core.controller.BaseController;
import com.blrs.common.core.domain.AjaxResult;
import com.blrs.common.enums.BusinessType;

import com.blrs.common.utils.poi.ExcelUtil;
import com.blrs.common.core.page.TableDataInfo;

/**
 * 阶段服务日志Controller
 * 
 * @author guobin
 * @date 2025-01-10
 */
@RestController
@RequestMapping("/service/log")
public class StageServiceLogController extends BaseController
{
    @Autowired
    private IStageServiceLogService stageServiceLogService;

    /**
     * 查询阶段服务日志列表
     */
    //@PreAuthorize("@ss.hasPermi('brls:log:list')")
    @GetMapping("/list")
    public TableDataInfo list(StageServiceLog stageServiceLog)
    {
        startPage();
        List<StageServiceLog> list = stageServiceLogService.selectStageServiceLogList(stageServiceLog);
        return getDataTable(list);
    }

    /**
     * 导出阶段服务日志列表
     */
    //@PreAuthorize("@ss.hasPermi('brls:log:export')")
    @Log(title = "阶段服务日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StageServiceLog stageServiceLog)
    {
        List<StageServiceLog> list = stageServiceLogService.selectStageServiceLogList(stageServiceLog);
        ExcelUtil<StageServiceLog> util = new ExcelUtil<StageServiceLog>(StageServiceLog.class);
        util.exportExcel(response, list, "阶段服务日志数据");
    }

    /**
     * 获取阶段服务日志详细信息
     */
    //@PreAuthorize("@ss.hasPermi('brls:log:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(stageServiceLogService.selectStageServiceLogById(id));
    }

    /**
     * 新增阶段服务日志
     */
   // @PreAuthorize("@ss.hasPermi('brls:log:add')")
    @Log(title = "阶段服务日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StageServiceLog stageServiceLog)
    {
        return toAjax(stageServiceLogService.insertStageServiceLog(stageServiceLog));
    }

    /**
     * 修改阶段服务日志
     */
    //@PreAuthorize("@ss.hasPermi('brls:log:edit')")
    @Log(title = "阶段服务日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StageServiceLog stageServiceLog)
    {
        return toAjax(stageServiceLogService.updateStageServiceLog(stageServiceLog));
    }

    /**
     * 删除阶段服务日志
     */
    //@PreAuthorize("@ss.hasPermi('brls:log:remove')")
    @Log(title = "阶段服务日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(stageServiceLogService.deleteStageServiceLogByIds(ids));
    }

    /**
     * 根据项目ID删除服务日志
     */
    @Log(title = "服务日志管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/project/{projectId}")
    public void removeByProjectId(@PathVariable String projectId) {
        stageServiceLogService.deleteStageServiceLogByProjectId(projectId);
    }
}
